package com.poetize.plus.entity.vo;

import com.poetize.plus.entity.po.Label;
import io.swagger.v3.oas.annotations.media.Schema;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author zuosy
 * @Date 2024/3/30 16:57
 **/
public record LabelVO(
        @Schema(description = "id")
        Long labelId,
        @Schema(description = "分类ID")
        Long sortId,
        @Schema(description = "标签名称")
        String labelName,
        @Schema(description = "标签描述")
        String labelDescription
) {
        /**
         * 实体类转vo
         * @param label
         * @return
         */
        public static LabelVO convert(Label label){
                return new LabelVO(label.getLabelId(), label.getSortId(), label.getLabelName(), label.getLabelDescription());
        }

        /**
         * 实体类集合转vo集合
         * @param labelList
         * @return
         */
        public static List<LabelVO> convertList(List<Label> labelList){
                List<LabelVO> result = new ArrayList<>();
                labelList.forEach(label -> result.add(convert(label)));
                return result;
        }
}
